package com.neusoft.yuejian_01.model;

import com.neusoft.yuejian_01.base.BaseModel;
import com.neusoft.yuejian_01.javabean.AttentionBean;
import com.neusoft.yuejian_01.javabean.IsAttentionBean;
import com.neusoft.yuejian_01.listener.RetrofitListener;
import com.neusoft.yuejian_01.service.AttentionService;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by Administrator on 2017/10/12.
 */

public class AttentionModel extends BaseModel {
    //判断关注
    public void isCollected(String u_id, String select_id,String flag, final RetrofitListener listener) {
        this.flag = Const.IsAttention;
        AttentionService attentionService = retrofit.create(AttentionService.class);
        final Call call = attentionService.isCollected(u_id,select_id,flag);
        call.enqueue(new Callback<IsAttentionBean>() {

            @Override
            public void onResponse(Call<IsAttentionBean> call, Response<IsAttentionBean> response) {
                IsAttentionBean isAttentionBean=response.body();
                listener.onSuccess(isAttentionBean, Const.IsAttention);
            }
            @Override
            public void onFailure(Call<IsAttentionBean> call, Throwable t) {
                listener.onFail();
            }
        });
    }
    //关注俱乐部
    public void userCollectClub(String u_id, String c_id,final RetrofitListener listener) {
        this.flag = Const.ClubAttention;
        AttentionService attentionService = retrofit.create(AttentionService.class);
        Call call = attentionService.userCollectClub(u_id,c_id);
        call.enqueue(new Callback<AttentionBean>() {
            @Override
            public void onResponse(Call<AttentionBean> call, Response<AttentionBean> response) {
                AttentionBean attentionBean=response.body();
                listener.onSuccess(attentionBean,flag);
            }
            @Override
            public void onFailure(Call<AttentionBean> call, Throwable t) {
                listener.onFail();
            }
        });
    }
    //关注活动
    public void userCollectActivity(String u_id, String a_id,final RetrofitListener listener) {
        this.flag = Const.ActivityAttention;
        AttentionService attentionService = retrofit.create(AttentionService.class);
        Call call = attentionService.userCollectActivity(u_id,a_id);
        call.enqueue(new Callback<AttentionBean>() {
            @Override
            public void onResponse(Call<AttentionBean> call, Response<AttentionBean> response) {
                AttentionBean attentionBean=response.body();
                listener.onSuccess(attentionBean,flag);
            }
            @Override
            public void onFailure(Call<AttentionBean> call, Throwable t) {
                listener.onFail();
            }
        });
    }
    //关注培训
    public void userCollectTrain(String u_id, String t_id,final RetrofitListener listener) {
        this.flag = Const.TrainAttention;
        AttentionService attentionService = retrofit.create(AttentionService.class);
        Call call = attentionService.userCollectTrain(u_id,t_id);
        call.enqueue(new Callback<AttentionBean>() {
            @Override
            public void onResponse(Call<AttentionBean> call, Response<AttentionBean> response) {
                AttentionBean attentionBean=response.body();
                listener.onSuccess(attentionBean,flag);
            }
            @Override
            public void onFailure(Call<AttentionBean> call, Throwable t) {
                listener.onFail();
            }
        });
    }
    //关注比赛
    public void userCollectMatch(String u_id, String m_id,final RetrofitListener listener) {
        this.flag = Const.MatchAttention;
        AttentionService attentionService = retrofit.create(AttentionService.class);
        Call call = attentionService.userCollectMatch(u_id,m_id);
        call.enqueue(new Callback<AttentionBean>() {
            @Override
            public void onResponse(Call<AttentionBean> call, Response<AttentionBean> response) {
                AttentionBean attentionBean=response.body();
                listener.onSuccess(attentionBean,flag);
            }
            @Override
            public void onFailure(Call<AttentionBean> call, Throwable t) {
                listener.onFail();
            }
        });
    }
    //关注大师
    public void userCollectProfessor(String u_id, String pm_id,final RetrofitListener listener) {
        this.flag = Const.ProfessorAttention;
        AttentionService attentionService = retrofit.create(AttentionService.class);
        Call call =attentionService.userCollectProfessor(u_id,pm_id);
        call.enqueue(new Callback<AttentionBean>() {
            @Override
            public void onResponse(Call<AttentionBean> call, Response<AttentionBean> response) {
                AttentionBean attentionBean=response.body();
             listener.onSuccess(attentionBean,flag);
            }
            @Override
            public void onFailure(Call<AttentionBean> call, Throwable t) {
                listener.onFail();
            }
        });
    }
    //关注发帖
    public  Call userCollectPost(String u_id, String p_id){
        AttentionService attentionService=retrofit.create(AttentionService.class);
        return attentionService.userCollectPost(u_id,p_id);
    }
}
